#!/bin/bash
# $Id: find-func.sh 711 2010-07-22 21:45:36Z ant_code $

wd=$PWD

obj_list="common-scripts common-scripts/gui installcd-initrd/init installcd-initrd/etc/scripts installcd-initrd/etc/scripts/gui host-initram/etc/scripts host-initram/init gentoo-files/installcd-initrd/etc/scripts/ gentoo-files/installcd-initrd/etc/scripts/gui gentoo-files/host-initram/etc/scripts/"

[ ! "$1" ] && { echo "1:{functionname|all} 2:{all,common,installcd,host}"; exit 1;}

case "$2" in
	"all")
		for o in $obj_list ; do
			if [ "$1" = "all" ]; then
				grep -r -E '*.\(\)' $wd/files/$o | grep -v "svn" 
				exit
			fi
			grep -r -E '*.\(\)' $wd/files/$o | grep -v "svn" | grep $1
		done
		;;
	"common")
		if [ "$1" = "all" ]; then
			grep -r -E '*.\(\)' $wd/files/common-scripts/*fn | grep -v "svn" 
			exit
		fi
		grep -r -E '*.\(\)' $wd/files/common-scripts/gui/*fn | grep -v "svn" | grep $1
		;;
	"installcd")
		if [ "$1" = "all" ]; then
			grep -r -E '*.\(\)' $wd/files/installcd-initrd/init | grep -v "svn" 
			grep -r -E '*.\(\)' $wd/files/installcd-initrd/etc/scripts/*fn | grep -v "svn" 
			grep -r -E '*.\(\)' $wd/files/installcd-initrd/etc/scripts/gui/*fn | grep -v "svn" 
			exit
		fi
		grep -r -E '*.\(\)' $wd/files/installcd-initrd/init | grep -v "svn" | grep $1 
		grep -r -E '*.\(\)' $wd/files/installcd-initrd/etc/scripts/*fn | grep -v "svn" | grep $1 
		grep -r -E '*.\(\)' $wd/files/installcd-initrd/etc/scripts/gui/*fn | grep -v "svn" | grep $1 
		;;
	"host")
		if [ "$1" = "all" ]; then
			grep -r -E '*.\(\)' $wd/files/host-initram/etc/scripts/*fn | grep -v "svn" | grep $1
			grep -r -E '*.\(\)' $wd/files/host-initram/init | grep -v "svn" | grep $1
			exit
		fi
		grep -r -E '*.\(\)' $wd/files/host-initram/etc/scripts/*fn | grep -v "svn" | grep $1
		grep -r -E '*.\(\)' $wd/files/host-initram/init | grep -v "svn" | grep $1
		;;
esac
